<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>通正健康咨询智能管理系统</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" href="../css/reset.css" />
<link rel="stylesheet" href="../css/common.css" />
<link rel="stylesheet" href="../css/page-common.css" />
<link rel="stylesheet" href="../css/Smoke520Theme/jquery-ui-1.10.3.custom.css" />
</head>
<body>
<div id="page">
    <div id="header">
        <img class="logo" src="../img/logo.png" alt="logo" width="170" height="40" />
        <div id="login-bar">
            <a href="#">注销</a> | <a href="#">退出</a>
        </div>
    </div>
    <div class="info-bar">
        <span>2013/07/10(星期日)</span><span>通正公司 XX部门</span><span>李四</span>
    </div>
    
  <div id="nav"> 
    <ul id="nav-main" class="util-clearfix">
      <li class="first"><a href="home.html">首页</a></li>
      <li><a href="#" url-data="#nav2">量表管理</a></li>
      <li><a href="#" url-data="#nav3">订单管理</a></li>
      <li><a href="#" url-data="#nav4">问卷管理</a></li>
      <li><a href="#" url-data="#nav5">对策编辑</a></li>
      <li><a href="#" url-data="#nav7">咨询建议</a></li>
      <li><a href="#" url-data="#nav1">基础信息管理</a></li>
      <li><a href="#" url-data="#nav6">报告管理</a></li>
      <li><a href="#">报表中心</a></li>
    </ul>
    <div class="nav-sub util-clearfix"> 
      <div class="nav-sub-body" id="nav1"><a href="managePart.html">数据字典</a> | 
        <a href="manageDeparment.html">部门管理</a> | <a href="manageArchitecture.html">组织结构管理</a> 
        | <a href="manageUser.html">用户管理</a> | <a href="managePower.html">权限分配</a></div>
      <div class="nav-sub-body" id="nav2"><a href="manageTable.html">量表管理</a> 
        | <a href="manageTableType.html">类型管理</a> | <a href="manageFormula.html">公式管理</a> 
        | <a href="managePrice.html">价格管理</a> | <a href="manageExplain.html">解释管理</a> 
        | <a href="assignTable.html">量表分配</a> | <a href="managePool.html">题库管理</a> 
        | <a href="manageDimension.html">维度管理</a> | <a href="manageConstant.html">常维管理</a> 
        | <a href="imageTemplate.html">图解模板</a> | <a href="manageExpertSuggestion.html">专家建议</a></div>
      <div class="nav-sub-body" id="nav3"><a href="manageOrder.html">订单管理</a> 
        | <a href="managePackage.html">套餐管理</a> | <a href="manageQuote.html">报价管理</a> 
        | <a href="manageSchedule.html">进度计划管理</a> | <a href="manageCustomer.html">客户信息管理</a></div>
      <div class="nav-sub-body" id="nav4"><a href="questionnaire.html">新增问卷</a> 
        | <a href="questionnaireList.html">问卷列表</a></div>
      <div class="nav-sub-body" id="nav5"><a href="manageCountermeasureP">个人</a> 
        | <a href="manageCountermeasureC.html">公司</a> | <a href="manageCountermeasureD">部门</a></div>
      <div class="nav-sub-body" id="nav6"><a href="manageReport.html">报告管理</a></div>
      <div class="nav-sub-body" id="nav7"><a href="manageExpert.html">专家管理</a> 
        | <a href="manageCategory.html">咨询类别设置</a> | <a href="manageSuggestion.html">建议管理</a></div>
    </div>
  </div>
    
  <div id="content" class="util-clearfix"> 
    <div id="main1"> 
      <div class="report-box"> 
        <div class="report-box-title util-clearfix"> 
          <div class="title-text">编辑公式</div>
        </div>
        <div class="report-box-body"> 
          <div class="tab-contents1"> 
            <div class="seach-table"> 
              <table>
                <tr> 
                  <th width="100">公式名称</th>
                  <td width="200"><input type="text" class="ui-textfield ui-textfield-system" />
                    &nbsp;&nbsp;</td>
                  <th width="100">量表名称</th>
                  <td><input type="text" class="ui-textfield ui-textfield-system" /></td>
                </tr>
              </table>
            </div>
            <div class="util-clearfix"> 
              <div class="ui-widget"> 
                <div class="ui-state-highlight ui-corner-all" style="margin-bottom:10px; padding:10px;"> 
                  <div> <span class="ui-icon ui-icon-info" style="float:left; margin-right:5px;"></span> 
                    <strong>温馨提示：</strong> 请点击选择维度列表与常维列表，接着请点击选择计算符号，在结果框内进行拖动排序位置，点击 
                    “X” 删除多余项。 </div>
                </div>
              </div>
              <div class="detail-score-ex"> 
                <div class="detail-score-ex-title">请选择维度列表</div>
                <div class="detail-score-ex-body2"> 
                  <table class="top-table target-list" width="100%">
                    <thead>
                      <tr> 
                        <th width="40">符号</th>
                        <th>维度名称</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr> 
                        <td class="target-item">Q1</td>
                        <td>XXXX</td>
                      </tr>
                      <tr> 
                        <td class="target-item">Q2</td>
                        <td>XXXX</td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
              <div class="detail-score-ex"> 
                <div class="detail-score-ex-title">请选择常维列表</div>
                <div class="detail-score-ex-body2"> 
                  <table class="top-table target-list" width="100%">
                    <thead>
                      <tr> 
                        <th width="40">符号</th>
                        <th>维度名称</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr> 
                        <td class="target-item">C1</td>
                        <td>XXXX</td>
                      </tr>
                      <tr> 
                        <td class="target-item">C2</td>
                        <td>XXXX</td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <div class="drag-wrapper"> 
              <div id="symbol-title" class="detail-score-ex-title"> 请选择计算符号 </div>
              <div id="symbol" class="util-clearfix"> <span>+</span><span>-</span><span>*</span><span>/</span><span>(</span><span>)</span> 
              </div>
              <div id="formula-result-title">结果</div>
              <ul id="formula-result" class="util-clearfix ui-sortable">
                <li class="drag-item ui-state-default target-name">Q1
                  <div class="drag-close">x</div>
                </li>
                <li class="drag-item ui-state-default">+
                  <div class="drag-close">x</div>
                </li>
                <li class="drag-item ui-state-default target-name">Q2
                  <div class="drag-close">x</div>
                </li>
                <li class="drag-item ui-state-default">-
                  <div class="drag-close">x</div>
                </li>
                <li class="drag-item ui-state-default target-name">C1
                  <div class="drag-close">x</div>
                </li>
                <li class="drag-item ui-state-default" style="position: relative;">*
                  <div class="drag-close">x</div>
                </li>
                <li class="drag-item ui-state-default target-name">C2
                  <div class="drag-close">x</div>
                </li>
              </ul>
            </div>
            <div class="detail-info-action"> 
              <form id="formula-form" action="" method="get">
                <input type="hidden" name="formula-reslut-tex" id="formula-reslut-text" />
              </form>
              <div class="ui-widget"> 
                <div class="ui-state-error ui-corner-all error-msg" id="formula-reslut-text-error" style="padding:10px"> 
                  <div> <span class="ui-icon ui-icon-alert" style="float:left; margin-right:5px;"></span> 
                    计算公式不能为空，请填写计算公式！ </div>
                </div>
              </div>
              <div class="ui-widget"> 
                <div class="ui-state-error ui-corner-all error-msg" id="formula-reslut-check-error" style="padding:10px"> 
                  <div> <span class="ui-icon ui-icon-alert" style="float:left; margin-right:5px;"></span> 
                    计算公式错误，请进行调整！ </div>
                </div>
              </div>
              <button class="ui-button-page ui-button-primary ui-button-medium" id="submit-btn">提交</button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

    <div id="footer">Copyright &copy; 2007-2012 XXXXX Group Co.Ltd All Rights Reserved</div>
</div>

<script src="../js/jquery-1.7.min.js"></script>
<script src="../js/nav.js"></script>
<script src="../js/jquery-ui-1.10.3.custom.min.js"></script>
<script>
    $('#symbol span').click(function(){
        $('#formula-result').append('<li class="drag-item ui-state-default">' + $(this).html() + '<div class="drag-close">x</div></li>');
        $('.drag-close').click(function(){
            $(this).parent('li').remove();
        });
        $('#formula-result').sortable({cursor:"move"});
        $('#formula-result').disableSelection();
    })
    $('.target-list tbody tr').click(function(){
        $('#formula-result').append('<li class="drag-item ui-state-default target-name">' + $(this).find('.target-item').html() + '<div class="drag-close">x</div></li>');
        $('.drag-close').click(function(){
            $(this).parent('li').remove();
        });
        $('#formula-result').sortable({cursor:"move"});
        $('#formula-result').disableSelection();
    })

    //提交表单 校验不能为空及公式不正确 公式赋值给hidden input id='formula-reslut-text';
    $('#submit-btn').click(function(){
        var resultText = '';
        var checkText = '';
        var checkFlag = '';
        $('#formula-result .drag-item').each(function(i){
            resultText += $(this).html().replace('<div class="drag-close">x</div>','');
            if($(this).hasClass('target-name')){
               checkText += '(1)';
            }else{
               checkText += $(this).html().replace('<div class="drag-close">x</div>','');
            }
        });
        $('#formula-reslut-text').val(resultText);

        try{
            eval(checkText);
            checkFlag = true;
        }catch(e){
            checkFlag = false;
        }
        
        if($('#formula-reslut-text').val()){
            $('#formula-reslut-text-error').hide();
            if(checkFlag && $('#formula-result .drag-item').length > 1){
                $('#formula-reslut-text-error').hide();
                $('#formula-reslut-check-error').hide();
                $('#formula-form').submit();
            }else{
                $('#formula-reslut-check-error').show();
            }        
        }else{
            $('#formula-reslut-check-error').hide();
            $('#formula-reslut-text-error').show();
        }
    });


</script>
</body>
</html>